package com.cloudkinto.enumType.claim;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.cloudkinto.vo.common.CommonKvVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author long
 */
public enum ClaimStatusEnum implements IEnum<Integer> {

    /**
     * 认领单状态
     */
    zero(0, "待认领"),
    one(1, "已认领"),
    two(2, "已取消"),
    three(3, "已过期");

    private final int value;
    private final String name;

    ClaimStatusEnum(int value, String name) {
        this.value = value;
        this.name = name;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    public static List<CommonKvVo> getClaimStatusList() {
        ArrayList<CommonKvVo> list = new ArrayList<>();
        for (ClaimStatusEnum claimStatusEnum : values()) {
            list.add(
                    CommonKvVo.builder()
                            .label(claimStatusEnum.name)
                            .value(claimStatusEnum.getValue())
                            .build()
            );
        }
        return list;
    }

    public static String getNameByValue(Integer value) {
        for (ClaimStatusEnum claimStatusEnum : values()) {
            if (claimStatusEnum.getValue().equals(value)) {
                return claimStatusEnum.name;
            }
        }
        return null;
    }
}
